package controller;

import java.awt.Scrollbar;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

/**
 * 12-01-2010
 * 
 * Makes the scrollbar move-able in the calendarmodel.
 * 
 * @author Dave Niewenhuijzen
 */
public class CalendarScrollbarController implements AdjustmentListener, MouseWheelListener {
	
	private model.CalendarModel calendarModel;

	/**
	 * Default constructor
	 * 
	 * @param setCalendarModel
	 */
	public CalendarScrollbarController(model.CalendarModel setCalendarModel) {
		calendarModel = setCalendarModel;
	}
	
	/**
	 * When the scrollbar is beeing used, the view goes down in the calendarmodel.
	 */
	public void adjustmentValueChanged(AdjustmentEvent e) {		
		calendarModel.setScroll((Scrollbar)e.getSource());
	}
	/**
	 * The scrollbar is usable with the mousewheel with this method.
	 */
	public void mouseWheelMoved(MouseWheelEvent e) {
		calendarModel.setScroll(e);
	}
}